#!/usr/bin/python

# Create some instances, and save them.

from pyodm.document import Document
from pyodm.fields import *

class ReferreeDocument(Document):
    field = StringField()

class ReferrerDocument(Document):
    field1 = StringField()
    field2 = IntegerField()
    ref = ReferenceField(ReferreeDocument)

obj = ReferrerDocument(field1="test1", field2="test2")
obj.save()

ref1 = ReferreeDocument(field="child1")
ref2 = ReferreeDocument(field="child2")
obj.ref.add(ref1)
obj.ref.add(ref2)

ref1.save()
ref2.save()
